import request from '@/utils/request'

// 登录
export function login(params) {
  return request({
    method: 'post',
    url: '/user/user/login',
    params
  })
}

// 注册
export function register(params) {
  return request({
    method: 'get',
    url: '/register',
    params
  })
}

// 退出
export function logout(params) {
  return request({
    method: 'get',
    url: '/logout',
    params
  })
}

// 用户管理列表查询
export function userQuery(params) {
  return request({
    method: 'get',
    url: '/user/user/query',
    params
  })
}

// 用户新增
export function userAdd(data) {
  return request({
    method: 'post',
    url: '/user/user/add',
    data: data
  })
}

// 用户更新
export function userUpdate(data, pikd) {
  return request({
    method: 'put',
    url: `/user/user/update/${pikd}`,
    data: data
  })
}

// 用户删除
export function userDelete(pikd) {
  return request({
    method: 'delete',
    url: `/user/user/delete?pkid=${pikd}`
  })
}

// 查询当前登录用户
export function userCurrent() {
  return request({
    method: 'get',
    url: '/user/user/current.json'
  })
}
// 用户登录日志查询
export function userLogQuery(params) {
  return request({
    method: 'get',
    url: '/user/log/login/query',
    params
  })
}

// 用户操作日志查询
export function userLogBehaviorQuery(params) {
  return request({
    method: 'get',
    url: '/user/log/behavior/query',
    params
  })
}

// 从平台登录
export function loginFromPlatform(code) {
  return request({
    method: 'post',
    url: `/user/single/user/sso/login?code=${code}`
  })
}
